<?php
/**
 * CreateUser:zlh
 * CreateTime:2022/1/15
 * Remark:该类Request作为基准方法
 */
namespace App\Http\Requests;

use App\Consts\ResponseConsts\ResponseCodeConsts;
use App\Func\ResponseFunc;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Http\Exceptions\HttpResponseException;

class BaseRequests extends FormRequest
{
    protected function failedValidation(Validator $validator) {
        $error= $validator->errors()->all();
        throw new HttpResponseException(ResponseFunc::returnJson(
            'error',
            null,
            $error[0],
            ResponseCodeConsts::OK_0_RESPONSE_CODE
        ));
    }
}
